package tk.eclipse.plugin.htmleditor.wizards;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import tk.eclipse.plugin.htmleditor.HTMLPlugin;
public class JSPNewWizard extends Wizard implements INewWizard {
private JSPNewWizardPage _page;
private ISelection _selection;
public JSPNewWizard() {
super();
setNeedsProgressMonitor(true);
setWindowTitle(HTMLPlugin.getResourceString("JSPNewWizardPage.Title"));
}
@Override
public void addPages(){
_page = new JSPNewWizardPage(_selection);
addPage(_page);
}
@Override
public boolean performFinish() {
IFile file = _page.createNewFile();
if(file==null){
return false;
}
try {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, file, true);
} catch(PartInitException ex){
HTMLPlugin.logException(ex);
return false;
}
return true;
}
public void init(IWorkbench workbench, IStructuredSelection selection) {
this._selection = selection;
}
}